﻿<?php
defined( '_VALID_MOS' ) or die( '非法链接.' );
require_once('common.inc.php');
require_once(_INC_PATH.'database.php');
require_once(_INC_PATH.'page.inc.php');

$cateid = $_REQUEST['cateid'];
$scaleid = $_REQUEST['scaleid'];
$typeid = $_REQUEST['typeid'];
$p = intval($_REQUEST['p']);

$smarty->assign("cateid",$cateid);
$smarty->assign("scaleid",$scaleid);
$smarty->assign("typeid",$typeid);
include_once( _INC_PATH."catecae.php" );
include_once( _INC_PATH."global.php" );
$smarty->assign("cateSubCae",$cateSubCae);
$smarty->assign("cor_scale_arr",$cor_scale_arr);
$smarty->assign("cor_type_arr",$cor_type_arr);

$where  = " where del_flg='0'";
if($cateid !== '99'){
	$cateid = ','.$cateid.',';
	$where .= "and concat(concat(',',ccid),',') like '%".$cateid."%'";
}
if($scaleid !== '99'){
	$where .= "and scale in ('".$scaleid."')";
}
if($typeid !== '99'){
	$where .= "and type in ('".$typeid."')";
}
$db = new database();
$sql = "select count(*) as total from tbl_corporation $where";  //echo $sql;
$total = $db->loadResult($sql);
$curPage = @intval($_REQUEST['p']);
if($curPage < 1) $curPage = 1;
$showNum = _FORVIEWNUM;
$pageLink = "/category/".$_REQUEST['cateid'].'_'.$_REQUEST['scaleid'].'_'.$_REQUEST['typeid'].'_'.$p.".html";
$page = new PageClass($total,$curPage,$showNum,$pageLink);
$limitStart = $page->limitStart;
$smarty->assign("pageList",$page->pageList);
$limit = " limit $limitStart,$showNum";

$sql = "select * from tbl_corporation $where $limit";
$db->setQuery($sql);
$rows = $db->loadList();
if(count($rows) > 0){
	foreach($rows as $key=>$value)
	{
		$imgPath = findImg($value['id']);
		if($imgPath == ""){
			$imgPath = "/images/noimage.jpg";
		}
		$rows[$key]['imgPath'] = $imgPath;
		$rows[$key]['description'] = mb_substr($value['description'], 0 ,50, "utf-8")."...";
	}
}
$smarty->assign("name",$cateSubCae[$_REQUEST['cateid']]);
$smarty->assign("rows",$rows);

/*企业排行**************************/
$sql = "select tc.* from tbl_corporation tc left join tbl_statistic ts on ts.cor_id=tc.id where tc.del_flg='0' order by ts.visit_total desc limit 10";
$db->setQuery($sql);
$rank_rows = $db->loadList();
$smarty->assign("rank_rows",$rank_rows);
/*企业排行 end**************************/

/*推荐企业**************************/
$sql = "select * from tbl_recom where del_flg='0' and type='qytj' limit 10";
$db->setQuery($sql);
$recom_rows = $db->loadList();
$smarty->assign("recom_rows",$recom_rows);
/*推荐企业 end**************************/
$pageinfo = Fetch("category.tpl");

$dir = _CATEGORY_PATH;
if(!is_dir($dir))cMkDir($dir);
$filename = $_REQUEST['cateid'].'_'.$_REQUEST['scaleid'].'_'.$_REQUEST['typeid'].'_'.$p.'.html';
writeFile($pageinfo, $dir.$filename);
echo $pageinfo;
?>